
pkgname=ncurses
pkgver=6.1
pkgrel=1
pkgdesc="System V Release 4.0 curses emulation library"
arch=('x86_64')
url="https://www.gnu.org/software/ncurses/"
license=('MIT')
depends=('glibc')
source=("https://ftp.gnu.org/gnu/ncurses/${pkgname}-${pkgver}.tar.gz")
md5sums=('98c889aaf8d23910d2b92d65be2e737a')

build() {
  cd ${pkgname}-${pkgver}
  
  ./configure --prefix=/usr \
      --mandir=/usr/share/man \
      --with-pkg-config=/usr/lib/pkgconfig \
      --with-pkg-config-libdir=/usr/lib/pkgconfig \
      --with-shared \
      --with-normal \
      --without-debug \
      --without-ada \
      --enable-widec \
      --enable-pc-files \
      --with-cxx-binding \
      --with-cxx-shared \
      --enable-ext-colors \
      --enable-ext-mouse
  make 
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
  
  for lib in ncurses ncurses++ form panel menu; do
    echo "INPUT(-l${lib}w)" > "$pkgdir"/usr/lib/lib${lib}.so
    ln -s ${lib}w.pc ${pkgdir}/usr/lib/pkgconfig/${lib}.pc
  done

  # look for -lcurses during build
  echo "INPUT(-lncursesw)" >"${pkgdir}/usr/lib/libcursesw.so"
  ln -sf libncurses.so ${pkgdir}/usr/lib/libcurses.so

  # install license
  install -d -m755 ${pkgdir}/usr/share/licenses/${pkgname}
  grep -B 100 '$Id' README > ${pkgdir}/usr/share/licenses/${pkgname}/license.txt
}

